package com.lnsf.bookstore.system.vipuser.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lnsf.bookstore.system.user.dao.UserMapper;
import com.lnsf.bookstore.system.user.dao.UserMapper;
import com.lnsf.bookstore.system.user.dao.UserRoleMapper;
import com.lnsf.bookstore.system.vipuser.dao.VipUserMapper;
import com.lnsf.bookstore.system.user.service.UserService;
import com.lnsf.bookstore.system.user.vo.User;
import com.lnsf.bookstore.system.vipuser.service.VipUserService;
import com.lnsf.bookstore.system.vipuser.vo.VipUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class VipUserServiceImpl implements VipUserService {

	@Autowired
	private UserMapper userMapper;

	@Autowired
	private VipUserMapper vipUserMapper;

	@Autowired
	private UserRoleMapper userRoleMapper;

	@Override
	public PageInfo<VipUser> selectAllVip(Map<String, Object> map, VipUser vipUser) {
		if(map.get("page")!=null && map.get("limit")!=null){
				PageHelper.startPage(Integer.parseInt(map.get("page").toString()),Integer.parseInt(map.get("limit").toString()));
		}
		//很多种会员
		map.put("parentId",4);
		return  new PageInfo<VipUser>(vipUserMapper.selectAll(map));
	}

	@Override
	public VipUser selectById(Integer uid) {
		return vipUserMapper.selectById(uid);
	}

	@Override
	public Integer saveVipUser(VipUser vipUser) {
		return  vipUserMapper.insertSelective(vipUser);
	}

	@Override
	public Integer updateVipUser(VipUser vipUser) {
		return vipUserMapper.updateByPrimaryKeySelective(vipUser);
	}

	@Override
	public int deleteBatch(Integer[] ids) {
		return vipUserMapper.deleteBatch(ids);
	}
}
